import React,{useState,useEffect} from 'react'
import {useSelector} from 'react-redux'
import {Button} from 'antd'

export default function AuthButton(props) {
  const [showBtn, setShowBtn] = useState(false)
  const btnAuth = useSelector((state) => state.user.permission)
  console.log('按钮权限: ',btnAuth,props)

  useEffect(()=>{
    const isB = btnAuth.some(item => item.menuName === props.type)
    setShowBtn(isB)
  },[])

  return showBtn ? <Button>{props.type}</Button> : <Button disabled>{props.type}</Button>
}
